/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package adventure_game;

import java.util.ArrayList;
import java.util.Set;
import java.util.HashMap;

/**
 * Holds room description.
 * @author Frank, Morten B, Ronni
 */
public class Room
{
    private String description;
    private HashMap<String, Room> exits;        // Saves the exit.
    private HashMap<String, Item> items;

    /**
     * make a description of the room
     */
    public Room(String description)
    {
        this.description = description;
        exits = new HashMap<String, Room>();
        items = new HashMap<String, Item>();
    }

    /**
     * Describes where the player is.
     */
    public String getDescription(boolean withExists)
    {
        String res = "" + description + "'s";
        if (withExists)
        {
            res += " " + getExitString();            
        }
        return res;
    }

    /**
     * Gives a description of the room you've entered.
     * @return
     */
    public String getShortDescription()
    {
        return "you have entered " + description;
    }

    /**
     * Returns the exits you can choose
     */
    private String getExitString()
    {
        String returnString = "exits are:";
        Set<String> keys = exits.keySet();
        for (String exit : keys)
        {
            returnString += " " + exit;
        }
        return returnString;
    }

    /**
     * Returns wich room you have enteret.
     * @param room
     */
    public Room getExit(String direction)
    {
        return exits.get(direction);
    }
/**
 * Returns wich rooms you can enter
 * @param direction
 * @param room
 */
    public void setExit(String direction, Room room)
    {
        exits.put(direction, room);
    }
/**
 * adds an item
 * @param item
 */
    public void addItem(Item item)
    {
        items.put(item.getName(), item);
    }
/**
 * Removes an item
 * @param itemName
 * @return
 */
    public Item removeItem(String itemName)
    {
        return items.remove(itemName);
    }
/**
 * Returns a item from the items hashmap
 * @param itemName
 * @return
 */
    public Item getItem(String itemName)
    {
        return items.get(itemName);
    }
/**
 * Returns a list of items from the items hashmap
 * @return
 */
    public ArrayList<Item> getItemList()
    {
        return new ArrayList<Item>(items.values());
    }
}


